<?php
/*
 * Copyright (C) 2010 TopCoder Inc., All Rights Reserved.
 */
namespace protocol\translation\framework\services\base;

require_once('PHPUnit/Framework.php');
require_once('log4php/Logger.php');
require_once('protocol/translation/framework/services/Helper.php');
require_once('protocol/translation/framework/services/Helper.php');
require_once('protocol/translation/framework/services/base/Base_Service.php');

/**
 * <p>
 * Unit tests for the Base_Service class. Since it is an abstract class, a concrete
 * implementation will be used to create the instance. In this case, Mock_Service
 * is used.
 * </p>
 *
 * @author akinwale
 * @version 1.0
 */
class Base_ServiceTests extends \PHPUnit_Framework_TestCase {
    /**
     * <p>
     * The Base_Service instance to be tested.
     * </p>
     *
     * @var Base_Service
     */
    private $service;

    /**
     * <p>
     * Setup for each unit test in the test case.
     * </p>
     */
    protected function setUp() {
        $this->service = new Mock_Service();
    }

    /**
     * <p>
     * Cleanup after each unit test in the test case.
     * </p>
     */
    protected function tearDown() {
        $this->service = null;
    }

    /**
     * <p>
     * Tests that the Base_Service() constructor creates a new instance that is not null.
     * </p>
     */
    public function testCtor() {
        $this->assertNotNull($this->service, "service should not be null");
    }

    /**
     * <p>
     * Tests that the setLogger(Logger) method works properly by retrieving the value
     * corresponding to the private field.
     * </p>
     */
    public function testSetLogger() {
        $logger = \Logger::getLogger("testLogger");
        $this->service->setLogger($logger);
        $this->assertEquals($logger, $this->service->getLogger(), "setLogger does not work properly");
    }

    /**
     * <p>
     * Tests that the getLogger() method works properly by retrieving the value
     * corresponding to the private field.
     * </p>
     */
    public function testGetLogger() {
        $logger = \Logger::getLogger("testLogger");
        $this->service->setLogger($logger);
        $this->assertEquals($logger, $this->service->getLogger(), "getLogger does not work properly");
    }

    /**
     * <p>
     * Tests that the setConverter(Converter) method works properly by retrieving the value
     * corresponding to the private field.
     * </p>
     */
    public function testSetConverter() {
        $converter = new SMPP_JSON_Converter();
        $this->service->setConverter($converter);
        $this->assertEquals($converter, $this->service->getConverter(), "setConverter does not work properly");
    }

    /**
     * <p>
     * Tests that the getConverter() method works properly by retrieving the value
     * corresponding to the private field.
     * </p>
     */
    public function testGetConverter() {
        $converter = new SMPP_JSON_Converter();
        $this->service->setConverter($converter);
        $this->assertEquals($converter, $this->service->getConverter(), "getConverter does not work properly");
    }

    /**
     * <p>
     * Tests that the setProtocolClient(Protocol_Client) method works properly by retrieving the value
     * corresponding to the private field.
     * </p>
     */
    public function testSetProtocolClient() {
        $client = new \stdClass();
        $this->service->setProtocolClient($client);
        $this->assertEquals($client, $this->service->getProtocolClient(), "setProtocolClient does not work properly");
    }

    /**
     * <p>
     * Tests that the getProtocolClient() method works properly by retrieving the value
     * corresponding to the private field.
     * </p>
     */
    public function testGetProtocolClient() {
        $client = new \stdClass();
        $this->service->setProtocolClient($client);
        $this->assertEquals($client, $this->service->getProtocolClient(), "getProtocolClient does not work properly");
    }
}

?>